package com.webSite.demo.cy.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.webSite.demo.cy.bean.HomeAbout;
import com.webSite.demo.cy.mapper.HomeAboutMapper;

@Controller
@EnableAutoConfiguration
public class HomeAboutController {

	@Autowired
	HomeAboutMapper homeAboutMapper;
	
	//显示公司简介(回显,已完成)
	@RequestMapping("/homeAboutUs.html")  
    String homeAboutUs(Model model) {
		HomeAbout about = homeAboutMapper.findLimitOne();
		if(about.getContent()!=null) {
			model.addAttribute("about", about);
		}else {
			model.addAttribute("about", "请输入公司简介");
		}
        return "admin/homeAboutUs";  
    }
	
	
	//添加关于我们(已完成)
	@RequestMapping("/addAbout.html")  
    String addAbout(HomeAbout about) {
		about.setCreated(new Date());
		about.setUpdated(new Date());;
		homeAboutMapper.insertHomeAbout(about);
        return "redirect:/homeAboutUs.html";  
    }
}
